//
// Created by lqk on 2022/1/29.
//

#ifndef QUADCEREBELLUM_PERIODICTASK_H
#define QUADCEREBELLUM_PERIODICTASK_H
#include <string>
#include <thread>
#include <vector>
#include <iostream>
#include "PeriodicTaskManager.h"
class PeriodicTaskManager;

class PeriodicTask {
public:
    PeriodicTask(PeriodicTaskManager* taskManager,const float& period,const std::string& name);
    void Start();
    void Stop();
    virtual void PrintStatus();
    virtual void Init()=0;
    virtual void RunOnce()=0;
    virtual ~PeriodicTask(){Stop();}
protected:
    void LoopFunction();
    virtual void CleanUp()=0;
    volatile bool m_isRunning=false;
    float m_period=0;
    float m_maxPeriod=0;
    std::string m_name;
    std::thread m_thread;

};



#endif //QUADCEREBELLUM_PERIODICTASK_H
